<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use DB;
use App\Http\Requests;
use App\Http\Controllers\Controller;

class HomeDetailController extends Controller
{
    public function getIndex()
    {
        return view('home.detail.show');
    }

    //前台商品详情
    public static function show($id)
    {
       //根据id查询商品信息
        $goods = DB::table('goods')
            ->join('cates', 'cates.id', '=', 'goods.pid')
            ->select('goods.*','cates.name as cname')
            ->where('goods.id',$id)
            ->first();

        //解析模板  分配变量
            return view('home.detail.show',['goods'=>$goods]);
    }

   
     public function postInsert(Request $request)
    {
        // echo 1111111;
         // dd($request->all());
        $comment = $request->input('content');

        $content = $request->except(['_token']);
        // dd($content);

        $res= DB::table('content')->insert($content);
        // die();
       
         return view('home.detail.show',['content'=>$content]);
        
    }


}
